<template>
  <view class="order">
    <view>
      <view class="filterDiv">
        <u-tabs-swiper ref="tabs" name="label" :list="tags" :is-scroll="false" @change="tagChange" :current="currentIndex" class="orderTab" active-color="#486be2"></u-tabs-swiper>

      </view>
      <view class="orderListDiv" v-if="orderList.length > 0">
        <scroll-view scroll-y class="orderListScroll" @scrolltolower="getList">
          <view class="orderList">
            <orderItem
              v-for="item in orderList"
              :key="item.orderNo"
              :info="item"
            />
          </view>
        </scroll-view>
      </view>
      <view class="empty" v-else-if="!loading">
        <image class="emptyImage" :src="getStaticDir('/empty.png')" />
        <text>暂无订单</text>
      </view>
    </view>
  </view>
</template>

<script>
// import { TOKEN } from '@/config/config';
import orderItem from './orderItem.vue';
// import { getSysDataDictList } from '@/api/volunteer';
// import {
//   getOrderList,
//   getOrderCount,
//   orderComment,
//   orderCancel,
//   getLabelList,
//   cycleComment
// } from '@/api/order.js';
export default {
  components: {
    orderItem
  },
  data() {
    return {
      currentIndex: 0,
      tags: [
        { name: '全部', num: '', active: true },
        { label: '待发货', num: '', active: false, code: 'HK_WAITING_GRAB' },
        { label: '待收货', num: '', active: false, code: 'HK_WAITING_RECEIVE' },
        { label: '已完成', num: '', active: false, code: 'HK_WAITING_DISTRIBUTE' },
        { label: '退货售后', num: '', active: false, code: 'HK_DEAL_AFTER_SALE' }
      ],
      orderList: [
        {
          orderNo:'11',
          orderState:'HK_FINISHED',
          productName:'大金柜'
        },
        {
          orderNo:'12',
          orderState:'HK_WAITING_COMPLETE',
          productName:'大金柜'
        },
        {
          orderNo:'13',
          orderState:'HK_WAITING_GRAB',
          productName:'大金柜'
        },
        {
          orderNo:'14',
          orderState:'HK_FINISHED',
          productName:'大金柜'
        },
        {
          orderNo:'15',
          orderState:'HK_WAITING_COMPLETE',
          productName:'大金柜'
        },
        {
          orderNo:'16',
          orderState:'HK_WAITING_GRAB',
          productName:'大金柜'
        }
      ],
      loading: false,
      page: 0
    };
  },
  computed: {
  },
  watch: {
  },
  mounted() {
    console.log('订单页挂载');
    // const token = uni.getStorageSync(TOKEN);
    // if (token) {
    //   this.refresh(true);
    // } else {
    //   this.reset();
    // }
  },
  activated() {
    console.log('订单页激活');
    // const token = uni.getStorageSync(TOKEN);
    // if (token) {
    //   this.refresh(true);
    // } else {
    //   this.reset();
    // }
  },
  methods: {
    tagChange(index){
      console.log(index);
      this.currentIndex = index;
    },
    // 失去焦点。ios系统键盘顶上去后无法恢复
    inputBlur() {
      document.activeElement.scrollIntoViewIfNeeded(true);
    },
    getList(e, page) {
      console.log(e, page);
      uni.showLoading();
      uni.hideLoading();
    }
  }
};
</script>

<style lang="scss" scoped>
 @import "./index.scss";
</style>
